﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DataAccessLayer.Entity;
namespace DataAccessLayer.Adapter
{
    public class DTUTAdapter
    {
        clsKetNoiCSDL kn = new clsKetNoiCSDL();
        public DataTable LoadDTUT()
        {
            return kn.LoadDL("tbDTUT_SelectAll");
        }
        public void ThemDTUT(clsDoiTuongUuTien clsDTUT)
        {
            int Npa = 3;
            string sql = "tbDTUT_Inser";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaDTUT"; value[0] = clsDTUT.MaDTUT;
            name[1] = "@TenDTUT"; value[1] = clsDTUT.TenDTUT;
            name[2] = "@DiemDTUT"; value[2] = clsDTUT.DiemTUT;
            kn.UpdateDL(sql,name,value,Npa);
        }
        public void SuaDTUT(clsDoiTuongUuTien clsDTUT)
        {
            int Npa = 3;
            string sql = "tbDTUT_Update";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaDTUT"; value[0] = clsDTUT.MaDTUT;
            name[1] = "@TenDTUT"; value[1] = clsDTUT.TenDTUT;
            name[2] = "@DiemDTU"; value[2] = clsDTUT.DiemTUT;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public void XoaDTUT(clsDoiTuongUuTien clsDTUT)
        {
            int Npa =1;
            string sql = "tbDTUT_Delete";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaDTUT"; value[0] = clsDTUT.MaDTUT;
            //name[1] = "@TenDTUT"; value[1] = clsDTUT.TenDTUT;
            //name[2] = "@DiemDTUT"; value[2] = clsDTUT.DiemTUT;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public object KiemTraMa(clsDoiTuongUuTien clsDTUT)
        {
            int Npa = 1;
            string sql = "tbDTUT_KiemTraMa";
            string []name=new string[Npa];
            object []value=new object[Npa];
            name[0] = "@MaDTUT"; value[0] = clsDTUT.MaDTUT;
            return kn.KTTrungMa(sql,name,value,Npa);
        }
    }
}
